package cn.hy.考试;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main011 {

    private static int ans;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[][] grid = new int[n][n];
        for (int i = 0; i < n; i++) {
            String[] split = sc.nextLine().split("\\s+");
            for (int j = 0; j < n; j++) {
                grid[i][j] = Integer.parseInt(split[j]);
            }
        }
        int k = Integer.parseInt(sc.nextLine()); // 服务
        int ans = 0;
        Set<Integer> set = new HashSet<>();


        for (int i = 0; i < n; i++) {

            if (grid[k-1][i] == 1) {

            }
        }


        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (grid[i][j] == 0) {
                    continue;
                } else if (grid[i][j] == 1) {
                    set.add(j);
                }
            }
        }

        System.out.println(ans);

    }


}
